package com.sunlands.zlcx.usercenter.vo;

import com.sunlands.zlcx.usercenter.domain.UserCardsDO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.Objects;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "用户名片")
public class UserCardsVO {

    @ApiModelProperty(position = 10, value = "用户id")
    private Long userId;

    @ApiModelProperty(position = 20, value = "用户名片")
    private String card;

    @ApiModelProperty(position = 30, value = "0、微信1、手机号")
    private Integer type;

    @ApiModelProperty(position = 40, value = "创建时间")
    private Date createTime;

    @ApiModelProperty(position = 50, value = "更新时间")
    private Date updateTime;

    public static UserCardsVO from(UserCardsDO userCards){
        return Objects.isNull(userCards) ? null :
                UserCardsVO.builder()
                .userId(userCards.getUserId())
                .card(userCards.getCard())
                        .type(userCards.getType())
                .createTime(userCards.getCreateTime())
                .updateTime(userCards.getUpdateTime())
                .build();
    }


    public static UserCardsDO from(UserCardsVO userCards){
        return Objects.isNull(userCards) ? null :
                UserCardsDO.builder()
                        .userId(userCards.getUserId())
                        .type(userCards.getType())
                        .card(userCards.getCard())
                        .build();
    }


}
